package primetest.faces;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;


import primetest.dto.ChargeDto;

public class ChargeListModel extends ListDataModel<ChargeDto> implements SelectableDataModel<ChargeDto> {

	public ChargeListModel(List<ChargeDto> bookList){
		super(bookList);
	}

	@Override
	public ChargeDto getRowData(String rowKey) {
		@SuppressWarnings("unchecked")
		List<ChargeDto> bookList = (List<ChargeDto>)getWrappedData();
		for (ChargeDto bookDto : bookList) {
			if(bookDto.getKey().equals(rowKey)){
				return bookDto;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(ChargeDto bookDto) {
		return bookDto.getKey();
	}

}
